package cn.lk1234.imt.controller;

import java.io.IOException;
import java.sql.SQLException;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.lk1234.imt.bean.UserInfo;
import cn.lk1234.imt.service.UserService;

@Controller
public class RegisterController {
	@Autowired
	public UserService userService;

	@RequestMapping(value = "/register")
	public @ResponseBody String register(UserInfo user) throws IOException, SQLException {
		String result = "OK";
		try { 
			int r = userService.registerUser(user);
			if (r > 0) {
				result = "OK";
			} else {
				result = "ERROR";
			}
		} catch (Exception e) {
			result = "ERROR:" + e.getMessage();
		}
		return result;
	}
}
